from lxml import etree
import requests

url = "https://quotes.toscrape.com"
res = requests.get(url)
tree = etree.HTML(res.text)

# items = tree.xpath('//div[@class="quote"]')
# for item in items:
#     content = item.xpath('./span[@class="text"]/text()')[0]
#     print(content)

# items = tree.cssselect('div.quote')
# for item in items:
#     content = item.cssselect('span.text')[0].text
#     print(content)

# 扩展
from cssselect import GenericTranslator

exp = GenericTranslator().css_to_xpath('div.quote>span.text')
print(exp)
